package com.duan.config;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import com.duan.utils.LocalIP;

import java.net.InetAddress;

public class IPConfig extends ClassicConverter {
    @Override
    public String convert(ILoggingEvent iLoggingEvent) {
//        String hostAddress = null;
//        try {
//            hostAddress = Inet4Address.getLocalHost().getHostAddress();
//        } catch (UnknownHostException e) {
//            e.printStackTrace();
//        }

        InetAddress localIPAddress = LocalIP.getLocalHostExactAddress();
        String hostAddress = localIPAddress.getHostAddress();
        System.out.println(hostAddress);

        String ipAddress = LocalIP.getIpAddress();
        System.out.println(ipAddress);
        return ipAddress;
    }
}
